<!DOCTYPE html>
<html>
<head>
    <title>Ectivise Cloud Login/Registration</title>
    <!--Custom Theme files-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content="Ectivise Cloud; GPON calculator"/>
    <script type="application/x-javascript"> addEventListener("load", function () {
        setTimeout(hideURLbar, 0);
    }, false);

    function hideURLbar() {
        window.scrollTo(0, 1);
    } </script>
    <!-- Custom Theme files -->
    <link href="css/style.css" rel="stylesheet" type="text/css" media="all"/>
    <!--web-fonts-->
    <link href='//fonts.googleapis.com/css?family=Jura:400,300,500,600' rel='stylesheet' type='text/css'>
    <!--//web-fonts-->
    <script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<script>
    $(document).ready(function () {
        //console.log("ready!");
        $("#bt_sendSMS").click(function () {
            // debugger
            var settings = {
                "async": true,
                "crossDomain": true,
                "url": "/sendsms",
                "method": "POST",
                "headers": {
                    "Content-Type": "application/x-www-form-urlencoded",
                    "cache-control": "yes",
                },
                "data": {
                    "i_mobile": $("#i_mobile").val(),
                    // "password": $("#i_pwd").val(),
                    "token": "",
                }
            }

            // debugger
            $.ajax(settings).done(function (response) {
                console.log(response);
                if (response.errorCode != 0){
                    alert('Error:' + response.message)
                }
                    //window.location.replace("http://localhost:8081/");
                //window.location.href('http://www.ectivisecloud.com');
                else alert(response.message)
            // else alert(response.message + '\n for the test purpose the code=' + response.data.sms)
            })
        })
    })
</script>
<!--<small>Provided by Ectivise Cloud Service</small>-->
<!-- main -->
<div class="main">
    <!--login-profile-->

    <!--login-profile-->
    <!--signin-form  All actions will be post to the / for processing-->
    <!--<div class="w3">-->
        <!--<div class="signin-form profile">-->
            <!--<h3>Login</h3>-->

            <!--<div class="login-form">-->
                <!--<form action="/" method="post">-->
                    <!--<input type="text" name="logemail" placeholder="E-mail" required="">-->
                    <!--<input type="password" name="logpassword" placeholder="Password" required="">-->
                    <!--<div class="tp">-->
                        <!--<input type="submit" value="LOGIN NOW">-->
                    <!--</div>-->
                <!--</form>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
    <div class="agile">
        <div class="signin-form profile">
            <h3>Mobile Login</h3>

            <div class="login-form">
                <form id="login" action="/" method="post" onsubmit="event.preventDefault(); validateMyForm();">
                    <div class="row">
                        <input type="text" id="i_mobile" name="logmobile" placeholder="Mobile Number" required="">
                        <button id="bt_sendSMS" class="btn btn-lg btn-primary btn-block" type="button" name="button"
                                value="Validate!">
                            Click to get SMS
                        </button>
                    </div>
                    <input type="text" name="i_otp" placeholder="OTP">
                    <input type="submit" value="VERIFY/LOGIN">
                </form>
            </div>
            <p><a href="#"> By verifying OTP to login.</a></p>
            <p><a href="#"> I agree to your terms</a></p>
        </div>
    </div>
    <div class="clear"></div>
    <!--//signin-form-->
</div>
<div class="copyright">
    <p> &copy; 2019 Ectivise Cloud. All rights reserved </p>
</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
    // debugger
    var passWordField = document.getElementById('password')
    var passWordConfirmField = document.getElementById('password_conf')
    var form = document.getElementById('login')

    function validateMyForm() {
        //validate the phone number if it's not Singapore mobile phone number then quit
        form.submit()
        //
        // if(false && passWordField.value != passWordConfirmField.value){
        // 	alert("Passwords do not match. Please try again.");
        // } else {
        // 	form.submit()
        // }
    }

</script>

</body>
</html>
